﻿#pragma once
#include <winsock2.h>
#pragma comment(lib,"ws2_32.lib")
#include <iostream>
#include <ws2tcpip.h>
#include <mutex>
#include <graphics.h>
#include <iomanip> // 用于格式化输出

struct DashboardData {
	//std::mutex mtx;
	float roll = 1500;
	float pitch = 1500;
	float yaw = 1500;
	float throttle = 1000;
	bool Running = false;
	bool isConnected = false;
	bool modeControl = true;
	std::string serverIP = "127.0.0.1";
	int serverPort = 25000;
};

// 安全关闭套接字的宏
#define SAFE_CLOSE_SOCKET(s) if(s != INVALID_SOCKET) { closesocket(s); s = INVALID_SOCKET; }

extern DashboardData droneData;

void udpServer(std::string serverIP, int serverPort);

void printDashboard(const DashboardData& data);